package com.sayimo.maker.activity.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sayimo.framework.exception.DaoException;
import com.sayimo.framework.exception.ServiceException;
import com.sayimo.maker.activity.dao.BaseSeckillGoodsDao;
import com.sayimo.maker.activity.service.BaseSeckillGoodsService;
import com.sayimo.maker.activity.vo.BaseSeckillGoods;
import com.sayimo.maker.commons.Constant;

/**
 * @Copyright (c) 2016 广东省尚一互联网有限公司
 * @Project: schoolmallapi-2.0
 * @ClassName: BaseSeckillGoodsServiceImpl.java
 * @Description: 
 * @Author:	tanxin
 * @Date:2016年10月7日,下午4:07:42
 * @Version 1.0.0
 */
@Service(value="baseSeckillGoodsService")
public class BaseSeckillGoodsServiceImpl implements BaseSeckillGoodsService{
	
	@Autowired
	private BaseSeckillGoodsDao baseSeckillGoodsDao;
	
	/**
	 * 根据标示符查询活动时间段信息
	 */
	@Override
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public Map selectBaseSeckillGoodsIdentifier(String identifier,Integer seckillTimesId,Integer goodsType)
			throws ServiceException {
		Map resultMap = new HashMap();
		Map map=new HashMap();
		try {
			List<BaseSeckillGoods> list=new ArrayList<BaseSeckillGoods>();
			if(goodsType==1){
				list =baseSeckillGoodsDao.selectBaseSeckillGoodsIdentifier(identifier,seckillTimesId);
			}else if(goodsType==0){
				list =baseSeckillGoodsDao.selectBaseSeckillPreGoodsIdentifier(identifier,seckillTimesId);
			}
			
			map.put("seckillGoods", list);
			resultMap.put(Constant.DATA, map);
			resultMap.put(Constant.STATUS, Constant.STATUS_SUCCESS);
		} catch (DaoException e) {
			e.printStackTrace();
		}
		return resultMap;
	}

}
